﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using UserDemo.Areas.Admin.Models;
using UserDemo.Models;

namespace UserDemo.Areas.Admin.Controllers
{
    public class AdminAccountController : Controller
    {
        // GET: Admin/Account
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Login(AdminLoginModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.Name =="admin")
                {
                    Session["AdminUser"] = new LoginInfo
                    {
                        UserId = 1, LoginName = "admin", NickName = string.Empty, Role = Role.Admin
                    };

                    return Json(new ResultModel());
                }
                return Json(new ResultModel { Code = 2, Msg = "管理员用户名或密码不正确" });
            }
            return Json(new ResultModel { Code = 1, Msg = "无效的数据" });
        }
    }
}